<!DOCTYPE html>
<html xmlns:th="http://www.springframework.org/schema/jdbc">
<head>
    <meta charset="utf-8">
    <title>编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/components/layuiadmin/layui/src/css/layui.css">


    <script src="/manage/js/app.js"></script>
    
</head>
<body>
<style>
    .layui-form-item .layui-input-inline {
        width: 300px!important;
    }
    .layui-textarea{
           width: 300px!important;
    }
</style>
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">

    
    <div class="layui-form-item">
        <label class="layui-form-label">名称 </label>
        <div class="layui-input-inline">
            <input type="text" id="name" name="name" lay-verify="required" placeholder="请输入名称 " autocomplete="off" class="layui-input" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">年龄 </label>
        <div class="layui-input-inline">
            <input type="number" id="age" name="age" lay-verify="required" placeholder="请输入年龄 " autocomplete="off" class="layui-input" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别 </label>
        <div class="layui-input-inline">
            <input type="number" id="sex" name="sex" lay-verify="required" placeholder="请输入性别 " autocomplete="off" class="layui-input" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">爱好 </label>
        <div class="layui-input-inline">
            <input type="text" id="like" name="like" lay-verify="required" placeholder="请输入爱好 " autocomplete="off" class="layui-input" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">城市 </label>
        <div class="layui-input-inline">
            <input type="number" id="city" name="city" lay-verify="required" placeholder="请输入城市 " autocomplete="off" class="layui-input" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">禁用 </label>
        <div class="layui-input-inline">
            <input type="number" id="disable" name="disable" lay-verify="required" placeholder="请输入禁用 " autocomplete="off" class="layui-input" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">头像 </label>
        <div class="layui-input-inline">
            <input type="text" id="headUrl" name="headUrl" lay-verify="required" placeholder="请输入头像 " autocomplete="off" class="layui-input" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="time" name="time" placeholder="yyyy-MM-dd HH:mm:ss">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">更多信息</label>
        <div class="layui-input-inline">
            <input type="text" id="text" name="text" lay-verify="required" placeholder="请输入更多信息" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认提交">
    </div>
</div>

<script>
    layui.use(['laydate','upload','form'], function () {
        gcTestupdInit();
        gcTestupdFormSubmit()
    });

    function gcTestupdInit(){
          <!-- 初始化相关数据, 和父页面的值赋值到当前页 -->
          
         $('#name').val(parent.data.name);
         $('#age').val(parent.data.age);
         $('#sex').val(parent.data.sex);
         $('#like').val(parent.data.like);
         $('#city').val(parent.data.city);
         $('#disable').val(parent.data.disable);
         $('#headUrl').val(parent.data.headUrl);
         //时间
         layui.laydate.render({
              elem: '#time'
              ,type: 'datetime'
              ,trigger: 'click'
              ,position : 'fixed'
         });
         $('#time').val(parent.data.time);
         $('#text').val(parent.data.text);
          // 刷新,否则部分from 表单样式不生效
          layui.form.render();
    }

    function gcTestupdFormSubmit(){
          // 监听提交
          layui.form.on('submit(layuiadmin-app-form-submit)', function (data) {
                
                let result = Ajax.put(parent.gcTestUrl + "/" + parent.data.id, data.field);
                let index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
                parent.layer.msg(result.msg);
                //重载表格
                parent.gcTestRenderTable();
          });
    }
</script>
</body>
</html>
